﻿#region 头注释
/******************************************************************************
文件名称    :   HistoryService.cs
创建日期    :   2011-4-23 21:58:14
功能描述    :   History实体数据服务类
修改日志    :   
    2011-04-23 21:58  马利
*******************************************************************************/
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using Stone.Components.Entities;
using Dare.Utilities.Data;
using Stone.Data.Providers;

namespace Stone.Services.EntityServices
{
    /// <summary>
    /// History实体数据服务类
    /// </summary>
    public class HistoryService : EntityServiceTemplate<History, long, HistoryDataProvider>
    {

        public HistoryService(Application app)
            : base(app)
        {
        }

        public bool DeleteHistoryInfo(History history)
        {
            HistoryFamilyService historyFamilyService = Stone.Services.Application.Instance.GetDbService<HistoryFamilyService>();
            HistoryEndocrineService historyEndocrineService = Stone.Services.Application.Instance.GetDbService<HistoryEndocrineService>();

            try
            {
                if (history.HistoryEndocrineId.HasValue)
                {
                    historyEndocrineService.Delete(history.HistoryEndocrineId.Value);
                }
                if (history.HistoryFamilyId.HasValue)
                {
                    historyFamilyService.Delete(history.HistoryFamilyId.Value);
                }

                return Delete(history.Id);
            }
            catch
            {
                return false;
            }
        }
    }
}
